package com.mindether.llyblog.service;

import com.mindether.llyblog.dao.ArticleSearchDao;
import com.mindether.llyblog.pojo.ArticleSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
public class ArticleSearchService {
    @Autowired
    private ArticleSearchDao articleSearchDao;

    public void updateArticle(ArticleSearch articleSearch){
        articleSearchDao.save(articleSearch);
    }

    public Page<ArticleSearch> findByTitleOrContentLike(String keywords,int page,int size){
        PageRequest pageRequest=PageRequest.of(page-1,size);
        return articleSearchDao.findByContentOrTitleOrIntroLike(keywords,keywords,keywords,pageRequest);
    }

    public void deleteById(String id){
        articleSearchDao.deleteById(id);
    }
    public void addArticleIndex(ArticleSearch articleSearch){
        articleSearchDao.save(articleSearch);
    }
    public void updateArticleIndex(ArticleSearch articleSearch){

    }

}
